<template>
	<view>
		<view class="recommended-content">
			
			<view  v-for="(item,index) in list.data" :key="index" @click="go(item)">
		      <ListPart  class="recommended-part" :sourceDataProp="item"></ListPart> 
			<view v-if="index+1 != list.data.length">
			  <u-line ></u-line>
			</view>
		   </view>
		   <u-loadmore :status="list.loading" style="margin-bottom: 20rpx;" />
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import ListPart from "@/components/list/ListPart_"
	import {collectionList} from "@/services/collectionHistory"
	import {
		mapGetters,
	} from "vuex";
	export default {
		components:{
			ListPart
		},
		data() {
			return {
				list:{
					loading:'loadmore',
					data:[],
					config:{
						pageSize:5,
						page:1
					}
				},
			}
		},
		created(){
		  this.collectionListLoad()
		},
		onReachBottom(){
			if( this.list.loading  !=  'nomore'){
				this.list.config.page++
				this.collectionListLoad()
			}
			
			 
		},
		computed:{
		},
		methods: {
			async collectionListLoad(){
				this.list.loading = 'loading'
				 let res = await collectionList(this.list.config)
				 if(res.code == 200){
					 this.list.data =  [...this.list.data,...res.data]
					 if(res.data.length < this.list.config.pageSize ){
						  if(res.data.length == 0){
							   this.list.config.page--
						  }
						 this.list.loading =  'nomore'
					 }else{
						 this.list.loading =  'loadmore'
					 }
				 }
			},
			go(item){
				if(item.delete_time != null || item.shelves != 1){
					this.$refs.uToast.show({
						title: '该资源已下架',
						type: 'info',
					})
					return
				}
				if(item.type=='store'){
					uni.navigateTo({
						url:`../store/StoreContent?id=${item.id}`
					})
				}else if(item.type == 'housing'){
					uni.navigateTo({
						url:`../buildings/BuildingsContent?id=${item.id}`
					})
					
				}else if(item.type == 'building'){
					uni.navigateTo({
						url:`../buildings/Details?id=${item.id}`
					})
				}
				
				
			},
		}
	}
</script>

<style scoped lang="less">
         .recommended-content{
		  	width: 100%;
		  	margin-top: 30rpx;
		  	// border: 1rpx solid red;
		  	// height: 200rpx;
		  	// padding-right: 35rpx;
		  	display: flex;
		  	flex-direction: column;
			}
</style>
